package com.cmc6.websocket.config;

import com.cmc6.websocket.service.SocketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class DisposableConfig implements DisposableBean {

    @Resource
    SocketService socketService;

    /**
     * springboot 结束时执行
     */
    @Override
    public void destroy() {

        // socket全部下线
        socketService.offlineAllForCurr();

        log.info("netty-websocket 离线成功");

    }
}
